perm filename USEMUS.LCS[UP,DOC]18 blob sn#322010 filedate 1977-12-06 generic text, type T, neo UTF8
      **********  Using the Stanford-IRCAM MUSIC Program **********
        
      ******* WORK IN PROGRESS -- NOV 77 -- LELAND SMITH *********
        
      This manual is designed for use with the  PDP10  at  the  Stanford AI 
      lab.  In most cases this text will also apply to the  program in  use
      at the IRCAM lab in Paris.
        
      MUS10 is a complete sound generating  package  which  exists  on  the
      disk.  Other versions of the program exist under the names NEWMUS and
      KLMUS.  For first attempts type:
        
      	R MUS10 	
      	(All lines must be terminated with the 'RETURN' key.)
        
      At this point the program will type the message:
        
      	INPUT?
        
      Basically  there  are  two responses possible.   If the program is to
      receive  further  instructions  from  another  file  which  has  been
      prepared with an editing program, type:
        
      	NAME -- where NAME is the name of the file to be read.
      			(If NAME has an extension, it must be used!)
        
      If instructions are to be entered by means of the  teletype  keyboard
      (TTY mode), type carriage return (<CR>).
        
      At  this  point the sign  (>)  will appear which means the program is
      awaiting input.
        
      (It is possible that an error message  such  as  "Ill  mem.  rel"  or
      "Halt"  will  sometimes appear.  If this happens first type 'S' -- to
      restart the program -- and then type  in  exactly  whatever  you  had
      typed before.  If the error message recurs, find an "expert.")
        
        
      Most complete statements  to  be  read  by  MUS10  must  end  with  a
      semicolon.  Several  complete  statements  may be entered on a single
      line but it is best not to have the lines too long.   More  than  one
      line  may  be used for a single statement.  If the less-than sign (<)
      appears everything following on that line will be ignored.  Use  this
      for entering comments.
        
              *****  Note  that  the above rules DO NOT apply to the syntax
      	of the SCORE program.
        
      Already  present  in MUS10 is an "instrument" known as SIMP which has
      been set to play a test tone of 'A' (440 hz) for 1/2 second.
        
      In  order  to  play  this  tone, first get into TTY mode as described
      above, then type:
        
      	PLAY;SIMP;FINISH;
        
      When the computation ends "TEST.SND"  will be typed out.  This  means
      that  sound  data has  been   written  on  the  disk  under  the name
      "TEST.SND."   You will also be given  other information  such  as the
      maximum amplitude encountered, the number of  bits  per  sample, etc.

      Immediately  after   this   the  following   message   will   appear:
      SPEED NUM, <CR>, OR "X".  This  means  you have three  options.  <CR> 
      means to hit the "RETURN" key.  At this point hitting <CR> will cause
      computed sound to play (unless someone else's program  has  momentary  
      control  over  the devices you need.)  Each time you hit the "RETURN" 
      key the process will be repeated.

      The sound will be playing at SPEED 1.   The SPEEDs  available  are  0
      through  5.  0 plays 1/2 as fast as 1, hence an octave lower; 2 plays
      twice as fast; 3 plays four times as fast;  4 plays  eight  times  as
      fast;  5 plays sixteen times as fast.  If you  type  "X"  the program 
      will exit from the "play" mode and return the symbol ">", which means
      it is  waiting for some new command.  When "X" is typed, you will get
      the message "PLEASE DELETE SOUND FILE". This means that when you have 
      finished your work you should type <CALL>, then "DEL TEST.SND <CR> so
      the space on the disk taken up by your sound tests may be reclaimed.
      								             
      The speed at which the sound will play is determined by the  sampling
      rate which was  used during  the computation.   The default  sampling
      rate in 'MUS10' is 12800.  (See later  on how  to change this.) 

      If  you have typed an "X" but wish to return to "play" mode, type $P;
      where '$' indicates the 'ALT' key.


      ******************************************************

      The instrument SIMP has five parameters.

		P1 = begin time of note (in seconds)
		P2 = duration of note     "     "
		P3 = pitch
		P4 = amplitude
		P5 = wave form (or timbre)
        
      P1 and P2 will have the same significance in all instruments but  all
      higher   numbered   parameters   are  assigned   roles  according  to
      convenience.  (However  it  will  prove  useful to  apply  P3  and P4
      consistently as above.)
        
      Internally all pitch entries become  numerical,  however  the  twelve
      frequencies  of  the  tempered chromatic scale, from middle C (261.62
      hz) up to B may be used in MUS10 by typing the letter  names  of  the
      notes. The letters S = #  and   F = flat.
        
      Since  these  letters  merely represent the frequencies of each note,
      the octave range  may  be  changed  by  multiplying  or  dividing  by
      multiples of two.   Thus C or A in the octave below middle C would be
      entered as C/2 or A/2.   In the octave above the basic middle  octave
      these notes would be C*2 or A*2.
        
      	C -- 2 octaves down would be C/4
      	C -- 3 octaves down would be C/8
      	C -- 2 octaves up would be C*4
      	C -- 3 octaves up would be C*8 etc.
        
      To test the use of these letters try:
        
      	P3←C;PLAY;SIMP;FINISH;
        
      Now instrument SIMP  will compute middle  C instead of  A.  The  left
      arrow (←)  indicates that  the value  of  C has  been placed  in  P3,
      replacing any value that was  previously there.  (The left arrow  and
      the equals  sign[=] are  interchangeable in  this program.   In  some
      printings the left arrow will appear  as an "underline"[_].   Try not
      to be confused by this.)
        
      PLAY;SIMP;FINISH;  must  be typed so the new note will be computed.
      After it is first heard it may be repeated as indicated above.
        
      If frequencies other than those of  the  tempered  scale  are  to  be
      played, a number may be used instead of a letter.
        
      	P3←1000;PLAY;SIMP;FINISH; will play a tone at 1000 hz.
        
        
      The amplitude scale available is the range of numbers from 0 to 2047.
      (This  upper  limit  is  set  by the number of bits [12] used for the
      sound samples.  See appendix.) P4 has been set at 1000 for  the  test
      tone.  This may be reset using the same method as described before.
        
      	P4←100;P3←GS*2;PLAY;SIMP;FINISH;
        
      This will play a G# above the middle octave at amplitude 100.
        
      The duration of the tone may be changed be resetting P2.
        
      	P2←.1;  will play a note of 1/10 sec. duration.
        
      In general, test tones should rarely exceed 1" duration.
        
      When several parameters are to  be  changed  at  once  the  following
      type-in format should be used:
        
      	PLAY;SIMP 0 .2 FS/2 850;FINISH;
        
      This will play F# below middle C for 2/10" at an  amplitude  of  850.
      (Please  note  that  P5,  the  wave form for SIMP, will be dealt with
      later.)
        
      **********  COMMAS  **********
        
      Commas may be used to separate the parameters and if nothing precedes
      a  comma  the contents of that parameter remains unchanged.  Also any
      parameter numbers higher than the length of  the  list  will  not  be
      affected.
        
      	PLAY;SIMP , .3, , 1200;FINISH;  changes only P2 and P4.
        
      ******************************************************
        
      A string of notes may be played with the following input:
        
      	PLAY;SIMP 0 .2 C 1500;SIMP .2, , D;SIMP .4, , E;
      	 SIMP .6, , C;FINISH;
        
      In this case P1 must be updated for  each  note.  (Never  overlap  an
      instrument  with  itself.   Distortion  will  occur.)  P2,  the  note
      duration remains unchanged, so the commas suffice for the last  three
      notes.  P4, coming at the end of the list for  the  first  note  need
      only be stated once if it is not to change.
        
      Rests  are created by simply leaving some time between the end of one
      note (P1+P2) and the beginning of the next (the new P1).
        
      	PLAY;SIMP 0 .2 C;SIMP .5;FINISH; will play C  for  2/10",
      rest for 3/10" and then play another C for 2/10".
        
        
      **********  FUNCTIONS  **********
        
      The  wave  form  in P5 is entered by means of a name which is used by
      the program to locate a  list,  or  array,  of  numbers  (512)  which
      describe  the wave.  The names used for this purpose will always be F
      followed  directly  by  a  number.    These  arrays  will  be  called
      "functions."
        
      There are 6 functions in MUS10 when you first run it.   More  can  be 
      added at any time.  The functions present are F1, F2, F3, F4, F5  and
      F6.  F2 and F3 are  used  for envelopes, F1 describes a sine wave and
      F4, F5 and F6 are more complicated timbres.
        
      Functions may be created with an  external  program  called  FUNC  or
      within  MUS10  itself  by means of two routines called SYNTH and SEG.
      SYNTH is used to create composites made by adding  various  harmonics
      together.  The form of F1 could be changed in the following manner:
        
      	SYNTH(F1); 1,1  2,1  3,.5  999;
        
      In the three pairs of numbers, the first of each pair represents  the
      harmonic  number  and  the  second  the  relative  amplitude  of that
      harmonic.   Thus the ratios of harmonics 1, 2 and 3 will be 1:1:.5 .
        
      The size of the second number of each pair is important only  in  its
      relation to the other amplitude numbers.  The last  number,  999,  is
      used to signal the termination of a string of entries.
        
      Several pairs may entered and harmonic numbers up to 256 may be  used
      but  in  practice  great  care  must be taken to avoid the "foldover"
      effect which  occurs  when  frequencies  higher  than  one  half  the
      sampling rate are present. (See appendix.)
        
      It should be pointed out that the fundamental (harmonic #1) need  not
      be present in a wave.
        
              SYNTH(F1); 10,1  12,1  15,1  999; will give  the  three notes
      of a minor chord.  After this has been  entered  the  following  will
      cause a C minor chord to play:
        
      	PLAY;SIMP 0 .5 GS/8;FINISH;
        
      While the lowest Ab (or G#) on the piano keyboard has been indicated,
      since  the wave form includes only the 10th, 12th and 16th harmonics,
      the notes middle C, Eb and G will be heard.
        
      Several  experiments  with  different  wave forms should be made.
        
      A function may be changed in the middle of a PLAY routine but it must
      be  noted that the new wave definition must follow! the note which it
      is to affect.
        
            In 	PLAY;SIMP 0 .3 D 1000; SIMP .3; 
                SYNTH(F1); 1,.7  3,.2  	5,.1  999; 
                SIMP .6,,E; FINISH;
        the newly defined wave will be heard in the second and third notes.
        
        
      If you wish to have several functions with different names  available
      and you do not create them with the FUNC program, their names must be
      "declared" to MUS10.  Suppose you wish to have F11, F12 and F14.  You
      must type directly to MUS10 (or into an  EDIT file which will be read
      by MUS10) the following:
        
         ARRAY F11,F12,F14(512);
        
      The "(512)" indicates that each function array will require 512 words
      of storage.
        
      The following example will play a sequence of notes wherein are heard
      the 10th, 14th and 18th harmonics of a low C, then the 10th, 13th and
      16th, and finally the 10th, 12th and 14th harmonics.
        
      	ARRAY F11,F12(512);
      	SYNTH(F11);10,1 14,1 18,1 999;
      	SYNTH(F12);10,1 13,1 16,1 999;
      	SYNTH(F1);10,1 12,1 14,1 999;
      	PLAY;SIMP 0 .3 C/4 2000 F11;
      	SIMP .3,,,,F12;SIMP .6,,,,F1;FINISH;
        
        
        
              From this point on it would probably be better to prepare any
      input  for MUS10 which requires more than a couple of lines of typing
      with the SOS or ET editors.   Typographical errors are inevitable and
      when an error is made near the beginning of a string of  input  typed
      directly to MUS10 you most likely will have to retype everything.
      A type of flow-chart diagram for SIMP would appear as follows:
        
      		 P4       MAG*P3
      		  |         |
      		  ↓         ↓
      		***************
      		*             *    OSCIL
      		*             *    U1 (UNIT GENERATOR ONE)
      	        *     P5      *
      	         *           *
      		  *         *
      		   *********
      		       |
      		       ↓
      		     *****
      		    * OUT *
      		    *  A  *
      		     *****
        
      The top left input, P4, serves simply as a multiplier for the numbers
      found  in  the  wave  form array, P5.  The particular number from the
      array to be multiplied is determined by the number in the upper right
      input.   The  upper  right  input, in this case P3, when processed by
      "MAG" (the "magic" number) becomes the increment, the rate  at  which
      the  wave form array is stepped through.  The "magic" number is found
      by dividing the array length, 512, by the sampling rate, 12800.
        
         512/SRATE=.04 (Higher sampling rates will be discussed later.)
        
      The  maximum  size of the numbers in the wave array is + or -1.  Thus
      if P4 is set to 1000 the output of the OSCIL will be numbers  in  the
      range  +1000  to  -1000 which will describe the wave form put into P5
      cycling at the rate given in P3.
        
        
      The code for entering this instrument follows:
        
      	INSTRUMENT SIMP;
      	OSCIL(P4,MAG*P3,P5);
      	OUTA←OUTA+U1;
      	END;
        
      This  instrument  has  only  one unit generator (the OSCIL) hence the
      output of U1 is added to the contents of OUTA.  If there are  several
      instruments  the  outputs  of all the instruments will be combined in
      OUTA for each sample.
        
      It will be noticed when playing instrument SIMP that the sound begins
      and ends quite abruptly.  This is because  no  attack-decay  envelope
      has been applied to the tone.  The sound begins at the full amplitude
      of P4 and remains at that level for  its  total  duration.
        
      To apply an envelope, another unit generator must be added.
        
        
      		 P4       MAG/P2
      		  |         |
      		  ↓         ↓
      		***************
      		*             *    OSCIL
      		*             *    U1 (UNIT GENERATOR ONE)
      	        *     P5      *
      	         *           *
      		  *         *
      		   *********
       		       |
      		       | 	 MAG*P3
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *             *    OSCIL
      		     *             *    U2 (UNIT GENERATOR TWO)
      	             *     P6      *
      	              *           *
      		       *         *
      		        *********  		INSTRUMENT TOOT;
      		            |			OSCIL(P4,MAG/P2,P5);
      		            ↓			OSCIL(U1,MAG*P3,P6);
      		          *****			OUTA←OUTA+U2;
      		         * OUT *		END;
      		         *  A  *
      		          *****
        
      To create  this  instrument the definition listed above must be typed
      in.  Now that the instrument has been expanded you will note that  it
      is the output of unit generator two (U2) which goes to OUTA.
        
      P5 will now contain the envelope array.   This array is best  defined
      by the SEG routine.   SEG defines the positions of line segments used
      to approximate a curve.   With SEG several pairs of  numbers  may  be
      entered.   The first number of each pair is an amplitude, normally in
      the  range of 0 to 1, and the second is the step number in the array.
      The step numbers 1 through 100 are used in SEG.   (However  the  step
      numbers are  converted  internally to 512 array locations.)  Straight
      line segments are drawn between each of the  points  defined.     The
      following would put a triangular envelope shape into F11.
        
      	ARRAY F11(512);
      	SEG(F11); 0,1  1,50  0,100;
        
          Note that the routine is terminated when step 100 is reached.
          DO NOT USE 999 with SEG.
        
      After having typed in the code for instrument TOOT and the definition
      for an  envelope in F11, the following will produce a note using that
      envelope:
        
      	SYNTH(F1);1,1  2,.4   3,.1 999;< Sets the tone color.
      	PLAY;TOOT 0 .5 A 2000 F11 F1;FINISH;
        
      If two envelopes are to be contrasted add another function and define
      it.

      	ARRAY F12(512);
      	SEG(F12); 0,1  1,7  .2,25  .1,60  0,100;< Staccato

      	PLAY;
        TOOT 0 .2 1000 2000 F12 F1;  < P5 has envelope
      	TOOT .2 .5,,,F2;
        FINISH;<Plays stac. then sust.(F12 then F2)
        
      In the next example a unit generator will be added  above  the  right
      side  of  the  bottom,  tone producing unit generator.  In this way a
      function may be used to describe fluctuations  of  pitch  within  the
      duration  of  a  note  --  much  as  the  previous  example  gave the
      possibility for changing the amplitude during a single note.
        
        
      				 MAG*P7-MAG*P3       MAG/P8
      	 P4       MAG/P2		   |         |
      	  |         |			   ↓         ↓
      	  ↓         ↓			 ***************
      	***************			 *	       *   OSCIL
      	*	      *	 OSCIL		 * 	       *   U2
      	*             *  U1     	 *     P9      *
      	*     P5      *      		  *           *
         *           * 			   *	     *
          *         * 			    *********
      	   ********* 	   MAG*P3		|
      	       |	       |   _____________|
      	       |________      _↓___↓_
      		       |      \     /
      		       |       \ + /
      		       |        \_/
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *		   *
      	     OSCIL   *             *
      	     U3	     *     P6      *
      	              *           *
      		       *         *
      		        *********     INSTRUMENT GLISS;
      		            |	      OSCIL(P4,MAG/P2,P5);
      		            ↓	      OSCIL(MAG*P7-MAG*P3,MAG/P8,P9);
      		          *****	      OSCIL(U1,MAG*P3+U2,P6);
      		         * OUT *      OUTA←OUTA+U3;
      		         *  A  *      END;
      		          *****
        
        
      In order for this instrument to perform glissandos, a third  function
      must  be  defined  for P9 (the "shape" of the glissando).  A straight
      line slope will suffice for a simple glissando.  After typing in  the
      instrument definition set up the three functions.
        
      	ARRAY F5,F6(512); <all these are already present.
      	SEG(F5);0,1  .8,7  1,12  1,90  0,100;<Envelope
      	SEG(F6);0,1  1,100; <Slope
        
      In the preceding, the ARRAY declaration is needed only when some  new
      function names are to be used.
        
      The following will play a glissando up two octaves, from C to C*4.
        
      	PLAY; GLISS 0 1 C 2000 F5  F1 C*4 1 F6; FINISH;
        
      If P8←.5; (while P2 remains at 1) two glissandos will be heard.
        
        
        
      This  instrument  may  be  used  for  a  dramatic  demonstration   of
      "foldover", the phenomenon  which occurs when a frequency exceeds the
      upper limit of one half the sampling rate.  (See Mathews' book for  a
      technical explanation.)
        
      For this purpose it is best to use a Sine wave in P6.
        
      	SYNTH(F1); 1 1  999; <note that this original form of F1
        
      	PLAY; GLISS 0 1 1000 2000 F5 F1 4000 1 F6;FINISH;
        
      This first note will slide up from 1000 hz to 4000 hz.
        
        
      	PLAY; GLISS 0 1 1000 2000 F5 F1 11800 1 F6;FINISH;
        
      Due to "foldover" (at 12800/2 hz.) this note will slide up to 6400 hz
      and return to the 1000 hz level even though 11800 hz was given in P7.
      The  general rule for "foldover" is that any frequencies which exceed
      one half the sampling rate will be heard at (SRATE-F) hz.
        
        
      Try this one!
        
      	PLAY; GLISS 0 1 0 2000 F5 F1 30000 1 F6; FINISH;
        
        
      This same instrument may be used to produce a vibrato  by  putting  a
      sine  wave into P9, setting P8←1/7; (the vibrato rate will be 7 times
      per second) and making P7 some very small amount different from P3.
        
      	PLAY; GLISS 0 1 C 2000 F5  F1 C+2 1/7 F1; FINISH;
        
      		(It is assumed that F1 is a sine wave.)
	      Various types of noise  and  other  random  fluctuations  are
      produced  by the two random number unit generators.  These are called
      RANDH and RANDI.  RANDH (H=hold) produces in effect a  function  made
      up  of  horizantal  lines at various levels with a perpendicular jump
      from one level to the next.  There are  two  inputs  to  RANDH.   The
      first   (left  hand)  gives  the  range,  plus  or  minus,  of random
      selection and the second (right hand) gives the rate (per  second) at
      which the selections are to be made.
        
      	      Care  must  be  taken with the number in the first input.  If
      the number 100 is given, the output of RANDH will  fluctuate  between
      +100  and  -100.  Thus if a range of 100 to 200 is desired, the input
      number should be 50 and the number 150 must be added to the output.
        
        
      				        MAG*P7     MAG*P8
      	 P4       MAG/P2	           |         |
      	  |         |		           ↓         ↓
      	  ↓         ↓			 ***************
      	***************			 *	       *
      	*	      *	 OSCIL		 *    RANDH    *   U2
      	*             *  U1     	 ***************
      	*     P5      *      		        |
         *           * 			        |
          *         * 			        |
      	   ********* 	   MAG*P3		|
     	       |	       |   _____________|
      	       |________      _↓___↓_
      		       |      \     /
      		       |       \ + /
      		       |        \_/
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *		   *
      	     OSCIL   *             *
      	     U3	     *     P6      *
      	              *           *
      		       *         *
      		        *********     INSTRUMENT NOISE;
      		            |	      OSCIL(P4,MAG/P2,P5);
      		            ↓	      RANDH(MAG*P7,MAG*P8);
      		          *****	      OSCIL(U1,MAG*P3+U2,P6);
      		         * OUT *      OUTA←OUTA+U3;
      		         *  A  *      END;
      		          *****
        
      			ARRAY F2(512); <F2 actually is already present.
      			SEG(F2);0,1  .8,7  1,12  1,90  0,100;<Env.
        
        
        
        
      	The following will produce white noise.
        
      	SRATE←25600;MAG←512/SRATE;
      	PLAY;NOISE 0 .5 C*8 1000 F2 F1 P3 P3*4;FINISH;
        
      	      Actually  P8 (given as P3*4) can probably be left at a number
      like 4000 for  noise  purposes.    As  P7  is  changed  the  apparent
      band-width  of  the  noise  will  be changed.  As the band-width gets
      narrower the center frequency becomes more apparent. Thus if P7←P3/16
      and  P3 is up in the range of C*8, something of the effect of blowing
      across an open tube will be produced.  The  pitch  is  clear  --  but
      quite windy.
        
      	      The  SRATE  (sampling  rate)  must  be  increased  for  noise
      production since very high frequencies are essential.  At SRATE←25600
      the high frequency cut-off will be at 12800 hz.
        
       **** For a simple way to reset the SRATE type the following:

      		SETMAG; 1 25600

      	    The first number, 1, refers to the number of channels and
      	the second is the sampling rate.  MAG, the magic number, will
      	be reset automatically.
        
      	If P8 is set to a  low  number  (e.g.  8)  individual  random
        pitches, instead of noise, will be produced at that rate.
        
        
      	      If the random unit generator  is  replaced  by  a  RANDI  the
      random  function  produced  will  be  made  up  of a series of slopes
      (I=interpolating) up and down from one random point to  another.   In
      the case of noise production there is little difference between RANDI
      and RANDH.  However RANDI is necessary for  getting  such  things  as
      random  vibrato.    The following will produce an acceptable, "human"
      sounding vibrato.
        
      	PLAY; NOISE 0 1 C*2 1000 F2  F1 P3*.01 16; FINISH;
        
      	      The random rate of 16 per  second  (in  P8)  is  considerably
      faster  than  the  human  vibrato rate of 5 to 8 per second.  In this
      case however since  the  full  band-width  (in  P7)  is  only  seldom
      attained and the heard effect is that of a rate much slower than 16.
        
      With an ordinary OSCIL there is no simple way to  have  a  long  note
      keep  the  same  characteristics of attack and decay as a short note.
      The LINEN unit generator is used to create  envelopes  with  separate
      controls over attack time, decay time and steady state.
        
        
      	  	  P7   P8   P9
      	 	  |    |    |
      	P4	  ↓    ↓    ↓        VAR
      	| 	***************       |
      	|      *               *      |     LINEN	
      	|     *                 *     |   U1 (UNIT GENERATOR ONE)
      	|___ *        P5         * ___|
      	    *                     *
      	   *                       *
      	  ***************************
      		       |
      		       | 	 MAG*P3
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *             *    COSCIL
      		     *             *    U2 (UNIT GENERATOR TWO)
      	             *     P6      *
      	              *           *       VARIABLE VAR;
      		       *         *	
      		        *********  	  INSTRUMENT LIN;
      		            |		  LINEN(P4,P7,P8,P9,P5,VAR);
      		            ↓		  COSCIL(U1,MAG*P3,P6);
      		          *****		  OUTA←OUTA+U2;
      		         * OUT *	  END;
      		         *  A  * 	
      		          *****
        
        
        
      The parameter arrangement for LINEN is rather different from that for
      OSCIL.  The far left parameter (P4) is, as usual, an amplitude input.
      The next three (P7, P8  and  P9  in  this  particular  example)  will
      receive  the  attack  duration,  the  decay  duration  and  the total
      duration of the envelope, in  that  order.   The  next  item  in  the
      parameter  list  (P5 here) will contain the envelope array name.  The
      last item is an "I-time" variable which  is  needed  to  ensure  that
      each note uses the correct portion of the overall envelope.   (I-time
      refers to the fact that it is referenced only at  the  beginning,  or
      input time, of each note.)
        
      The internal workings of LINEN make it unnecessary to use "MAG"  with
      the  3  time  domain  parameters.   The  proper conversion of time to
      increments is automatic.  The 3rd parameter (P9) of this group  could
      have  been  P2.  However since P2 is always a special parameter which
      tells how long the instrument is to be turned, its  use  to  indicate
      the  total  duration of the envelope would make it impossible to play
      several notes within one envelope cycle (a phrase.)
        
      The array used for LINEN must be defined in a special way.  Only  the
      first 3/4 of the available locations are to be used.  When using SEG,
      steps 1-25 are reserved for the attack portion, steps 26-50  for  the
      "steady  state"  and steps 51-75 for the decay portion.  Steps 76-100
      are ignored by LINEN but must be included in the SEG input  in  order
      for  the SEG routine to conclude properly.  To test the properties of
      LINEN it is best to construct an envelope with dramatic changes.
        
      	ARRAY F2(512);
      	SEG(F2); 0,1  1,2  .3,25  1,50  0,75  0,100;
        
      If parameters 7, 8 and 9 are set properly, this  array  will  give  a
      sharp  attack  followed  by  a  return to a low amplitude (.3) at the
      start of the "steady state"  section.   Following  there  will  be  a
      relatively  slow  crescendo to full amplitude and then a rapid decay.
      It must be emphasized that the sum of the values given for P7 and  P8
      (attack  and  decay)  must  never  exceed  the  value  of  P9  (total
      duration.) Likewise, P9 should never be less than P2, (the total time
      the instrument is turned on for a single note.) To visualize the true
      shape of the envelope for any particular note duration (ND)  consider
      that  the  time  spent in the middle section of the array (SS="steady
      state" area) will be what is left when the attack (AT) and decay (DK)
      are subtracted from the total duration (TD.)
        
      	SS = TD - AT - DK
        
      	PLAY; LIN 0 1 A 2000 F2 F1 .08 .08 1; VAR=0; FINISH;
        
        
      The special  variable  VAR  is  used  to  reset  a  pointer  for  the
      initialization  of  the envelope.  A unique variable must be used for  
      each LINEN unit generator.  The variable must be set to 0 immediately 
      after! each detached note or after the first note of a phrase.
        
      In  the  following,  the 2 notes D, F will be connected (phrased) and
      the 3rd note, C#, will be detached.   Notice  that  the  first  value
      given  in  P9  (total  duration  of  envelope)  represents  the total
      duration of the first 2 notes.  P9 is changed to  equal  P2  for  the
      separate note.
        
      	PLAY; LIN 0 .5 D 2000 F2 F1 .08 .08 1; VAR=0;
      	LIN .5 .5 F;    < P4 to P9 remain the same.
      	LIN  1 .5 CS 2000 F2 F1 .08 .08 .5; VAR=0;
      	FINISH;
        
        
      You will have noticed that the last unit generator in this instrument
      is called a COSCIL.  This is exactly like an OSCIL  except  that  the
      pointer  to  the array is never re-initialized.  This allows the wave
      form produced to be continuous from one note to the next.   (The  "C"
      indicates it is a "continuing" OSCIL).  If an OSCIL were used in this
      situation clicks would often be heard between phrased notes.
        
      	      Frequency modulation allows for  the  production  of  a  wide
      variety  of  tone  colors  using relatively little compute time.  The
      INTRP unit generator is really just a  combination of an OSCIL and an
      ADD box.  The left input represents the output when the function (P10
      below) is at zero and the right input represents the output when  the
      function  is  at  1  (peak  amplitude).   No time input is given with
      INTRP.  The speed of stepping through the function  array  is  always
      taken  as  being  P2,  i.e. the note duration.  In this case P10 will
      contain an envelope which  will  control  the  changes  in  frequency
      modulation.   For  a  full  explanation of FM see John Chowning's AES
      Journal article on this subject.
        
        
      				 P9*P7*MAG    P8*P9*MAG
      				      |         |
      				      ↓         ↓
      				    ***************
      				     *           *
      				      *   P10   *   INTRP
      				       *       *    U2
      					*     *
      					 *   *
      					  * *
      				           *         P9*MAG
      	 P4       MAG/P2		   |         |
      	  |         |			   ↓         ↓
      	  ↓         ↓			 ***************
      	***************			 *	       *   OSCIL
      	*	      *	 OSCIL		 * 	       *   U3
      	*             *  U1     	 *     P11     *
      	*     P5      *      		  *           *
         *           * 			   *	     *
          *         * 			    *********
      	   ********* 	   MAG*P3		|
      	       |	       |   _____________|
      	       |________      _↓___↓_
      		       |      \     /
      		       |       \ + /
      		       |        \_/
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *		   *
      	     NOSCIL  *             *
      	     U4	     *     P6      *
      	              *           *
      		       *         *
      		        *********     INSTRUMENT FM;
      		            |	      OSCIL(P4,MAG/P2,P5);
      		            ↓	      INTRP(P7*P9*MAG,P8*P9*MAG,P10);
      		          *****	      OSCIL(U2,P9*MAG,P11);
      		         * OUT *      NOSCIL(U1,U3+P3*MAG,P6);
      		         *  A  *      OUTA←OUTA+U4;
      		          *****	      END;
        
        
        
      	You will notice that the last OSCIL is here changed to a NOSCIL.
      	This is necessary because FM often requires that the frequency
      	given the last unit generator is negative.  If an OSCIL were
      	used here an error message would result.
        
        The following functions should be set up to test the FM instrument.
        
      	ARRAY F1,F2,F3(512); < all these are already declared in MUS10
      	SYNTH(F1); 1 1 999;   < A sine wave.
      	SEG(F2);0,1  .9,4  1,8  1,72  .8,88  .5,95  0,100; < Envelope
      	SEG(F3); 0,1  1,100;  < An upward slope or ramp.
        
      The following will produce a shift from a pure sine tone to a
      highly modulated tone over a period of 2 seconds.
        
      	PLAY; FM 0 2 100 1000 F2   F1 0 10 100 F3  F1; FINISH;
        
        
      To reverse the procedure, i.e. change from the modulated tone
      to the pure tone, reverse the values of P7 and P8.
        
      	P7←10; P8←0; PLAY;FM;FINISH;
        
        
      Change F2 (the ramp) to make the modulation  emerge  only  in
      the mid-part of the note.
        
      	SEG(F2); 0,1  1,50  0,100;  < Makes a triangle.
        
      	PLAY;FM;FINISH;
        
      	Try several of the variations suggested in Chowning's article.
        
      *********  STEREO SOUND  ***************
        
      		 P4       MAG/P2
      		  |         |
      		  ↓         ↓
      		***************
      		*             *    OSCIL
      		*             *    U1 (UNIT GENERATOR ONE)
      	        *     P5      *
      	         *           *
      		  *         *
      		   *********
       		       |
      		       | 	 MAG*P3
      		       |         |
      		       ↓         ↓
      		     ***************
      		     *             *    OSCIL
      		     *             *    U2 (UNIT GENERATOR TWO)
      	             *     P6      *
      	              *           *
      		       *         *
      		        *********  		
      			    |			  INSTRUMENT STER;
      		 P7__       |	    __(1-P7)	  OSCIL(P4,MAG/P2,P5);
                     \     / \ 	   /		  OSCIL(U1,MAG*P3,P6);
                      *___/   \___*		  OUTA←OUTA+U2*P7;
      		      ↓           ↓		  OUTB←OUTB+U2*(1-P7);
      		    *****       *****		  END;
      		   * OUT *     * OUT *		  NCHNS←2;
      		   *  A  *     *  B  *
      		    *****       *****
        
        
        
      	      Any instrument may have stereo capability by simply adding an
      OUTB.  NCHNS is normally set to 1 in MUS10.  For stereo NCHNS must be
      set to 2.  This causes the sound samples to be multiplexed.  That is,
      the odd numbered samples will be for channel A and the even numbered
      samples  will  be  for  channel B.   (Thus twice as many samples are
      computed for the same duration of sound.)
        
             In the above example the use of a number between zero and 1 in
      P7 will control the stereo position.   If P7←1 all the sound will  be
      be directed to OUTA.  If  P7←0 all the sound will be directed to OUTB.
      When P7←.5 then 50% of the sound will go to each channel.
      Try the following:
        
             PLAY; STER 0 .3 A 1000 F2 F1 1; P7←0; STER .4; FINISH;
        
      Note  that  a  unit generator may replace P7.  Thus, depending upon 
      the shape of the function used, a single, continuous sound may be 
      caused to move from channel to channel.
      ***************** CONDITIONALS WITHIN AN INSTRUMENT *****************
        
      Any  instrument  definition  may  include  ALGOL-like  conditional
      statements.  ALGOL statements may  include IF, WHILE, FOR,  UNTIL,
      THEN, DO, DONE, EXIT,  END, ELSE, BEGIN and  STEP and the  special
      symbols for equals(=), not equal (≠), less than (<), greater  than
      (>), less than or equal (≤) and greater than or equal (≤).   Also,
      special functions using these terms may be written independent  of
      instrument    definitions.     Examples    may    be    seen    in
      INIT.MUS[MUS,LCS].   See  MUS10.DOC[MUS,LCS]  for  details.    See
      SCORE.LCS[UP,DOC]  concerning the  use of  these functions  within
      play lists.
        
      In the following  stereo instrument  (the design as  given on  the
      previous page) the stereo position  of the sound is determined  by
      the pitch range of  the note.  Notes  at 100 hz  or lower will  be
      heard in channel A.  Notes at 1100 hz or higher will be in channel
      B.  A note at 600 hz will appear half way between A and B, etc.
        
      In the second set of conditionals the particular function for tone
      color is also determined by pitch.  The lowest notes will use  F6,
      the medium low range will use  F5, the medium high range will  use
      F4 and the highest range will use F1.
        
      These conditionals may be used for a wide variety of purposes.
        
        
      INSTRUMENT STERX;
      P7 ← (P3-100)/1000;
      IF P7 > 1 THEN P7 ←1;
      IF P7 < 0 THEN P7 ←0;< stereo position determined by pitch.
        
      P6←F6; IF P3 > D/2 THEN P6←F5; <tone choice also set by pitch.
      IF P3 > C*2 THEN P6←F4; IF P3 > F*4 THEN P6←F1;
        
      OSCIL(P4,MAG/P2,P5);
      OSCIL(U1,MAG*P3,P6);
      OUTA←OUTA+U2*P7;
      OUTB←OUTB+U2*(1-P7);
      END;
      NCHNS←2;
        
      Try the following play list.  It is assumed that 4 different  tone
      functions have been set up in F1, F4, F5 and F6.
        
                            PLAY; STERX 0 .5 A/4 1000 F2;
                            STERX .5 .5 A/2;
                            STERX  1 .5 A*2;
                            STERX 1.5 .5 A*4;  FINISH;

      It will be noted  that no mention  is made of P6  or P7.  This  is
      because these two parameters will  be determined for each note  by
      the ALGOL code within the instrument.
        
      ************* INSTRUMENTS CONTROLLING OTHER INSTRUMENTS ***********
        
             P4     MAG/P2
       	     ↓         ↓
           ***************
           *             *  OSCIL
           *             *
           *     P5      *	 VARIABLE /PX4;
            *	        *	 INSTRUMENT AMPL;
             *         * 	 PX4 ← OSCIL(P4,MAG/P2,P5);
              ********* 	 END;
                  |
                  ↓ 	
                 PX4        PX4*P4     MAG/P2
        		       |         |
      			       ↓         ↓
      			     ***************
      It is possible to	     *             *   OSCIL
      use the output of	     *             *   U1 (UNIT GENERATOR ONE)
      one instrument to      *     P5      *
      influence  other        *           *
      instruments.  In	       *         *
      the above instrument,     *********
      'AMPL', the output is	    | 	    MAG*P3
      directed  to  the RUN-        |         |
      TIME variable PX4. PX4	    ↓         ↓
      is  then   used  as  a      ***************
      multiplier   on   the 	  *             *   OSCIL
      amplitude input of the      *             *   U2 (UNIT GENERATOR TWO)
      of  the  envelope  of	  *     P6      *
      instrument 'INS1'. (The      *           *
      same PX4 could be used        *         *
      in connection  with  a         *********      INSTRUMENT INS1;
      group  of  instruments             |	    OSCIL(PX4*P4,MAG/P2,P5);
      similar to 'INS1'.)  In            ↓	    OSCIL(U1,MAG*P3,P6);
      this manner an amplitude         *****	    OUTA←OUTA+U2;
      function may be entered	      * OUT *	    END;
      in P5 of 'AMPL' for the         *  A  *	    PX4←1;
      purpose  of  controlling         *****
      amplitude shifts over a
      long series of  notes.  Instrument  'AMPL' would be  turned on  once
      while 'INS1' plays several  notes.  Each of  INS1's notes will  have
      its own envelope but the amplitude will be constantly scaled by PX4.
      If 'AMPL' is not used with 'INS1' then PX4 must be set to 1 so  that
      the amplitude numbers entered  in P4 will function  as they have  in
      the other instruments described.  For an example of the use of  this
      system try the following.
        
      	ARRAY F7(512);
      	SEG(F7); .02,1  1,30  .1,80  .01,100; <OVER-ALL AMPL. SHIFTS
      	SEG(F1); 0,1  1,8  1,90  0,100; <THE ENVELOPE
      	SYNTH(F4);1,.5  3,.3  5,.2  7,.1  999; < TIMBRE
        
      	PLAY; AMPL 0 8 0 1 F7; <CONTROLS OVER-ALL AMPL.
      	INS1 0 .2 C 1000 F1 F4;  INS1 .2 .2 E;  INS1 .4 .2 G ;
      	INS1 .6 .2 A;  INS1 .8 1.6 BF;  INS1 2.4 ; < REPEATS THE BF
      	INS1  4 1.6 B; INS1 5.6 .2 C*2; INS1 5.8 .2 BF;
      	INS1  6 .2 AF; INS1 6.2 .2 G ;  INS1  6.4 1.6 FS; FINISH;
 
      ****** READING IN AND PROCESSING EXTERNAL DIGITAL SOUND FILES *****

      A special set of subroutines in the MUS10 program may be called to
      read in as  many as  4 external sound  files simultaneously.   The
      basic information for initializing this capability is found in the
      file  'READ[MUS,LCS]'.  This  file,  which  contains  four  READIN
      functions,  'READIN',   'READI2',   'READI3'  and   'READI4',   is
      reproduced in full below.

      The first lines are needed to declare the presence of some machine
      language routines  which read  external files  from the  disk  and
      unpack the samples in the proper manner.  The second set of  lines
      set up  the necessary  arrays for  temporarily storing  the  sound
      samples.  Then a group of variables are declared for  transferring
      various kinds of information for each 'READIN' function.

      SCNT, SCNT2, SCNT3 and SCNT4  are the overall sample counters  for
      each 'READIN' unit.   They must  be set to  zero each  time it  is
      desired to read from the beginning of a file.  After this  counter
      exceeds the length of the file  then zeros will be sent back  from
      the function.

      CNT, CNT2, etc. are sample counters  which are used to keep  track
      of when a new sample buffer must be read in.  The other  variables
      carry the following information:

         RD = the value of the current sample.
         INCH = NCHNS of the file
         INSR = SRATE of the file
         INDR = duration of the file in samples
         INBT = bits per sample   (0 = 12,  1 = 18)
         INBUF = 1536 if 12-bit samples, 1024 if 18-bit samples.
         INMX = maximum amplitude of file

      Note that RD, CNT and SCNT must be 'run-time' variables because
      their values must be read for every sample.

      ********************************************************************
      EXTERNAL FUNCTION GETINF(ARRAY J,INSR,INBT,INCH,INMX,INDR),
      RDSMPL(ARRAY N,BITS),GETIN2(ARRAY J,INSR,INBT,INCH,INMX,INDR),
      RDSMP2(ARRAY N,BITS),GETIN3(ARRAY J,INSR,INBT,INCH,INMX,INDR),
      RDSMP3(ARRAY N,BITS),GETIN4(ARRAY J,INSR,INBT,INCH,INMX,INDR),
      RDSMP4(ARRAY N,BITS);
 
      ARRAY INF, IN2, IN3, IN4(1536);
      VARIABLE /CNT,/RD,/SCNT,INCH,INSR,INMX,INDR,INBT,INBUF,
      /CNT2,/RD2,/SCNT2,INBT2,INBUF2,
      /CNT3,/RD3,/SCNT3,INDR3,INBT3,INBUF3,
      /CNT4,/RD4,/SCNT4,INDR4,INBT4,INBUF4;
 
      FUNCTION PRNTIT(CNT,INBT,INDR,INBUF);  
      BEGIN  VARIABLE DUR;  <***** don't forget to init. SCNT←0; ****
        INBUF←1535-512*INBT;  DUR←INDR/INSR/INCH;
        PRINT "SRATE=",INSR," BITS=",12+INBT*6," NCHNS=",INCH,
        " MAXAMP=",INMX," DUR=",DUR;
        CNT←2000;     < ANY NUMBER > 1536
      END;

      FUNCTION READIN(RD);
      BEGIN 		<***** DON'T FORGET TO INIT SCNT ← 0;
        IF SCNT=0 THEN BEGIN  <****** READ HEADER INTO ARRAY INF.
        PRINT "****READING ",INFILE,".SND****";
          GETINF(INF,INSR,INBT,INCH,INMX,INDR);
          PRNTIT(CNT,INBT,INDR,INBUF);
        END;
      SCNT←SCNT+1;  < ***** UPDATE THE COUNTER
      IF SCNT > INDR THEN  BEGIN <***CHECK IF SMPL CNT IS EXCEEDED
        RD←0;  RETURN(RD); END;
      IF CNT > INBUF THEN BEGIN
        RDSMPL(INF,INBT);   <**** GET A NEW BUFFER WHEN NECESSARY
        CNT←0;  END;
      RD←INF(CNT);  <**** PUT VALUE OF SAMPLE INTO RD
      CNT←CNT+1; <**** UPDATE THE COUNTER
      RETURN(RD); END;   <**** VALUE OF RD IS RETURNED IN READIN(RD)

      FUNCTION READI2(RD2);  < ***** DUPLICATE OF 'READIN' *****
      BEGIN 
        IF SCNT2=0 THEN BEGIN  
          PRINT "****READING ",INFIL2,".SND****";
          GETIN2(IN2,INSR,INBT2,INCH,INMX,INDR2); 
          PRNTIT(CNT2,INBT2,INDR2,INBUF2);
        END;
      SCNT2←SCNT2+1;
      IF SCNT2 > INDR2 THEN  BEGIN 
        RD2←0;  RETURN(RD2); END;
      IF CNT2 > INBUF2 THEN BEGIN
        RDSMP2(IN2,INBT2);
        CNT2←0;  END;
      RD2←IN2(CNT2); 
      CNT2←CNT2+1; 
      RETURN(RD2); END; 

      FUNCTION READI3(RD3);
      BEGIN 		
        IF SCNT3=0 THEN BEGIN  
          PRINT "****READING ",INFIL3,".SND****";
          GETIN3(IN3,INSR,INBT3,INCH,INMX,INDR3); 
          PRNTIT(CNT3,INBT3,INDR3,INBUF3);
        END;
      SCNT3←SCNT3+1;
      IF SCNT3 > INDR3 THEN  BEGIN 
        RD3←0;  RETURN(RD3); END;
      IF CNT3 > INBUF3 THEN BEGIN
        RDSMP3(IN3,INBT3);
        CNT3←0;  END;
      RD3←IN3(CNT3);
      CNT3←CNT3+1; 
      RETURN(RD3); END; 

      FUNCTION READI4(RD4);
      BEGIN 		
        IF SCNT4=0 THEN BEGIN  
          PRINT "****READING ",INFIL4,".SND****";
          GETIN4(IN4,INSR,INBT4,INCH,INMX,INDR4); 
          PRNTIT(CNT4,INBT4,INDR4,INBUF4);
        END;
      SCNT4←SCNT4+1;
      IF SCNT4 > INDR4 THEN  BEGIN 
        RD4←0;  RETURN(RD4); END;
      IF CNT4 > INBUF4 THEN BEGIN
        RDSMP4(IN4,INBT4);
        CNT4←0;  END;
      RD4←IN4(CNT4);
      CNT4←CNT4+1; 
      RETURN(RD4); END; 
    ***********************************************************

      The file 'READ' also contains the following possible READIN 
      instruments.   These instruments simply put some over-all 
      amplitude envelope on the sound which is read in.
      The names of the files to be read in will be in INFILE for
      FUNCTION READIN, in INFIL2 for FUNCTION READI2, in INFIL3
      for READI3, and in INFIL4 for READI4.  !!!!! ONLY 5 LETTERS
      MAY BE USED FOR INPUT FILE NAMES AND THE EXTENSION SHOULD
      NOT BE USED (.SND IS ASSUMED.)!!!  Examples of how to set
      the input file names is found in the play list below the
      instrument definitions.

    ************************************************************

      SEG(F6);0 0 .7 20  .5 50  1 80  0 100; <ENVELOPE ON INPUT SOUND.
      INSTRUMENT READA;	<**** A POSSIBLE READIN INSTRUMENT.
      OSCIL(P4,MAG/P2,F6);
      OUTA←OUTA+U1*READIN(RD);
      END;
      INSTRUMENT READB;
      OSCIL(P4,MAG/P2,F6);
      OUTA←OUTA+U1*READI2(RD2);
      END;
      INSTRUMENT READC;
      OSCIL(P4,MAG/P2,F6);
      OUTA←OUTA+U1*READI3(RD3);
      END;
      INSTRUMENT READD;
      OSCIL(P4,MAG/P2,F6);
      OUTA←OUTA+U1*READI4(RD4);
      END;

      OUTFILE←"RD.SND";  <**** the extension must appear here.
      PLAY; 
      READA 0  .37  0 2; <*** amplitude will be doubled
      INFILE←"U";  <FILE NAME TO BE READ IN FOR NOTE ABOVE THIS LINE!!!
      SCNT←0; 	<initialize counter file above.
      READB .3  .37  0 1; <**** amplitude will be unchanged
      INFIL2←"A";   <FILE NAME TO BE READ IN. (.SND extension assumed.)
      SCNT2←0;       < intitialize the counter
      READC .8 .37  0 .7;  <**** note the amplitude
      INFIL3←"I";        <FILE NAME TO BE READ IN.
      SCNT3←0;
      READA 1.3 .37  0  .8;  SCNT←0; <*** use READA again
      INFILE←"U"; <FILE NAME TO BE READ IN FOR NOTE ABOVE THIS LINE!!!
      FINI;
 
    ********************************************************************

      Just before the above play list the output file name has been  set
      'RD.SND'.  (When the  output file  name is  changed the  extension
      must!! be given.)  Within the play list the mention of each READIN
      instrument is immediately  followed!! by the  input file name  and
      the initialization  of the  main sample  counter for  that  READIN
      function.
 
      The names of the  input files must have  the extension '.SND'  but
      the extensions should not  be typed here.   Parameter 2 tells  how
      long the READIN instrument is to be turned on.  Normally P2  would
      be set to at  least the duration  of the file  being read in.   In
      these instruments P4 can be used to scale the original amplitudes.
 
      Many different sorts of instruments may be designed to make use of
      the READIN  functions.   For example  mono  input samples  may  be
      processed into stereo output, the  samples may be reverberated  or
      the samples may be amplitude-modulated in many ways.
 
 
     ******** VARIABLE INCREMENT RATES IN READA **********************

      The following variant of the  READIN function allows you to  alter
      the increment, or reading rate, of  the input file.  This has  the
      effect of dynamically altering the sample rate of the input sound.
      To avoid rough edges, an  interpolation section has been added  to
      the READIN function.

     ******************************************************************

      EXTERNAL FUNCTION GETINF(ARRAY J,INSR,INBT,INCH,INMX,INDR),
      RDSMPL(ARRAY N,BITS);
 
      ARRAY INF(1536);
      VARIABLE /CNT,/RD,/SCNT,INCH,INSR,INMX,INDR,INBT,INBUF,
      IX,/INC,RX,JZ,IZ;

      FUNCTION PRNTIT(CNT,INBT,INDR,INBUF);  
      BEGIN 
        INBUF←1535-512*INBT ;     
        PRINT "SRATE=",INSR," BITS=",12+INBT*6," NCHNS=",INCH,
        " MAXAMP=",INMX," DUR=",INDR/INSR/INCH;
            INDR←INDR-2;
      END;

      FUNCTION READIN(RD);
      BEGIN 		<DON'T FORGET TO INIT AND SCNT ← 0;
        IF SCNT=0 THEN BEGIN        
          GETINF(INF,INSR,INBT,INCH,INMX,INDR); <HEADER IS READ INTO ARRAY INF.
          PRNTIT(CNT,INBT,INDR,INBUF);
           RDSMPL(INF,INBT);
     	   CNT←0;  JZ←0; RX←INF(0);
        END;
        SCNT←SCNT+INC; 
        IF SCNT > P6 THEN INC←INC+P5;<******SPECIAL FEATURE***************

        IF SCNT > INDR THEN  BEGIN <CHECK TO SEE IF SMPL CNT IS EXCEEDED
           RD←0;  RETURN(RD); END;
         IX ← INF(JZ);
         IZ←1-INT(JZ)+CNT;
            RD←RX+(IX-RX)*IZ;   < INTERPOLATION
        CNT←CNT+INC; <UPDATE THE COUNTER

        IF CNT < INBUF THEN RX←INF(CNT);
	JZ←CNT+1; 

        IF JZ ≥ INBUF THEN BEGIN
           RDSMPL(INF,INBT);
           JZ←JZ-INBUF;  
	   CNT←JZ-1;
	   IF CNT ≥ 0 THEN RX←INF(CNT);
       	    END;
        RETURN(RD); 
     END; 

     ************************************************************                

      INSTRUMENT READA;
      OUTA←OUTA+P4*READIN(RD);
      END;
      
      INC←1;  < MUST BE INITIALIZED.
      PLAY;
      READA  0  .37  0  1.3  .00025  1920;
      SCNT←0; INFILE←"U"; 
      FINISH;
 
    ***************************************************************
 
      In the above example P5  is used to cause  a slight change in  the
      increment rate.  P6  is used (in  the function) to  tell when  the
      increment rate will begin to change.   In the above case a  vowel,
      "ou" (human voice), is processed  to have an upward inflection  at
      the end.  The change  in the increment may  seem to be very  small
      but after 12800 samples (or 1 second) the increment will be up  to
      2.5.
      ********* PRELIMINARY INFORMATION REGARDING REVERBERATION *********
        
      ARRAY D1(801),D2(901),D3(1011),D4(1123),D5(123),D6(43),D7(13);
      VARIABLE /R;
      REVINIT←1;R←0;
        
      INSTRUMENT REV;
      REV1(R,801,.827,D1);
      REV1(R,901,.805,D2);
      REV1(R,1011,.783,D3);
      REV1(R,1123,.764,D4);
      REV2(U1+U2+U3+U4,123,.7,D5);
      REV2(U5,43,.7,D6);
      REV2(U6,13,.7,D7);
      R←0;OUTA←OUTA+U7;
      END;
        
      IN THE EXAMPLE ABOVE THE TOP LINE DECLARES THE ARRAYS TO BE  USED.
      THE  RUN-TIME  VARIABLE,  R,  PICKS  UP  DATA  FROM  THE   REGULAR
      INSTRUMENTS TO PASS ON TO THE REV INSTRUMENT.  When a variable  is
      declared with a preceding slash ( /R ) it is known as a "run-time"
      variable.  This means that,  unlike ordinary parameters which  are
      read by an instrument  only at the beginning  of a note (at  input
      time, or "I-time"), a "run-time" variable is read or changed every
      time a sample is computed.  ORDINARY VARIABLES [NO SLASH WHEN THEY
      ARE FIRST  DECLARED] ARE  FIXED EACH  TIME THE  PARAMETERS FOR  AN
      INSTRUMENT ARE READ IN.

      EVERY TIME INSTRUMENT REV  COMPUTES A SAMPLE, R  IS SET BACK TO  0
      (LINE JUST ABOVE 'END') SO THAT DATA FROM ONE SAMPLE WILL NOT  MIX
      WITH THAT FROM THE  NEXT.  THE REV1 AND  REV2 UNIT GENERATORS  ARE
      ESSENTIALLY FEEDBACK LOOPS WITH DELAY TIMES (IN SAMPLES) EQUAL  TO
      THE FIRST NUMBER  APPEARING IN  THE PARENTHESES,  WITH THE  SECOND
      NUMBER (LESS THAN 1) BEING THE MULTIPLIER (OR GAIN) USED EACH TIME
      A SAMPLE MAKES THE LOOP.
        
      THE USUAL WAY TO  USE REVERBERATION IS TO  TAP THE OUTPUT OF  EACH
      INSTRUMENT, PUTTING A PERCENTAGE OF THE SIGNAL INTO R (USUALLY  10
      TO 20%).  THE RELATIONSHIP BETWEEN THE PERCENTAGE OF DIRECT SIGNAL
      TO THE PERCENTAGE OF REVERBERATED SIGNAL SEEMS TO BE THE THE  MOST
      IMPORTANT ELEMENT IN GIVING THE ILLUSION OF VARYING DISTANCES.
        
      IN THE FOLLOWING EXAMPLE IT WILL BE ASSUMED THAT 5 UNIT GENERATORS
      INVOLVING 8 PARAMETERS  ARE USED IN  THE INSTRUMENT PROPER.   THEN
      THE LAST LINES WOULD BE:
        
      	R←R+U5*P8;
      	OUTA←OUTA+U5*P9;
      	END;
        
      THUS P8 WILL HAVE THE PERCENTAGE OF THE SIGNAL TO BE REVERBERATED.
      THE PERCENTAGE OF THE SOUND CONSIDERED TO BE THE DIRECT SIGNAL  IS
      DETERMINED BY P9.  THE SUM OF P8 AND P9 CAN BE GREATER THAN 1, BUT
      REMEMBER  THAT  REVERBERATION  CAUSES   INCREASES  IN  THE   TOTAL
      AMPLITUDE WHICH ARE DIFFICULT TO REPEAT.
        
      IN GENERAL  THE REV  INSTRUMENT  SHOULD BE  TURNED ON  ONLY  ONCE,
      "PLAYING" ONE LONG  "NOTE" FOR THE  DURATION OF A  PIECE.  IN  THE
      FOLLOWING EXAMPLE THE ASSUMPTION IS THAT THE TOTAL DURATION OF THE
      REGULAR  NOTES  IS  42".   REV  PLAYS  2"  LONGER  TO  ALLOW   THE
      REVERBERATION TO DIE AWAY.
        
      	REVINIT←1;R←0;
      	PLAY;REV 0 42;
      	--- [ALL THE NOTES FOLLOW] --
      	FINISH;
        
      IF A LONGER WORK  (SAY 2 1/2')  IS TO BE DONE  IN SECTIONS --  FOR
      EVENTUALLY EITHER  ONE LONG  PLAY FROM  THE COMPUTER  OR FOR  TAPE
      SPLICING OF THE SEPARATE SECTIONS -- DO AS FOLLOWS:
        
      	REVINIT←1;R←0;
      	PLAY;REV 0 37.3;REVINIT←0;
      	--- [THE NOTES FOR EXACTLY 37.3" FOLLOW] --
      	FINISH;
        
         -- THEN, USING THE SAME CORE IMAGE (SO THE LAST STATE OF THE
      REVERBERATOR WILL BE PRESERVED):
        
      	PLAY;REV 0 78;
      	--- [NOTES FOR EXACTLY 78"] --
      	FINISH;
        
         -- THEN THE FINAL SECTION*
        
      	PLAY;REV 0 37;
      	--- [NOTES FOR THE LAST 34.7"] --
      	FINISH;
        
      WHEN THESE THREE PARTS ARE PIECED  TOGETHER THERE WILL BE NO  GAPS
      IN THE  REVERBERATION, WHICH  WILL EXTEND  2.3" BEYOND  THE  FINAL
      NOTE.
        
      I AM NOT  TOO SURE ABOUT  THE FUNCTION OF  REVINIT.  I BELIEVE  IT
      MUST BE SET BACK TO  ZERO AFTER! THE FIRST  PLAYING OF REV IF  YOU
      WISH TO HAVE THE REVERBERATION CARRY OVER FROM ONE PLAY;...FINISH;
      INTO THE NEXT.
        
        
        
        
      ********** APPENDIX XXX NOT COMPLETE!!!XXX  ************
        
      This main  program  for  sound  generation  is  currently found in
      MUS10A.FAI and MUS10B.FAI.  
      It should be found on the area [MUS,LCS].
        
      The main program must be loaded by means of the following  command
      file: MUS10.CMD   Type: LOAD @MUS10 

      		   When 'INPUT?' appears then type: INIT.MUS[MUS,LCS]
      		   This reads in all necessary initialization.
      		   At this point the core image should be saved
      		   under some appropriate name.
        
      Reading in  INIT.MUS  causes 5  instruments  and 6  functions  to  be
      predefined in MUS10.   This instrument  names are  SIMP, TOOT,  CLAR,
      BRIT and BUZZ.  Instrument SIMP is of the type described in the first
      section of  this  document.   It  has  no  envelope.   The  parameter
      structure is as follows.

      	P1 = begin time of note (in seconds)
      	P2 = duration of note     "     "
      	P3 = pitch
      	P4 = amplitude
      	P5 = wave form (or timbre)
        
      The other 4 instruments are all  of the same type (see section  3)
      however the tone-color parameter for each instrument is different.

      	P1 = begin time of note (in seconds)
      	P2 = duration of note     "     "
      	P3 = pitch
      	P4 = amplitude
      	P5 = envelope   (F2)
      	P6 = wave form (or timbre) for instrument TOOT  (F1)
      	P7 = wave form for instrument CLAR  (F4)
      	P8 = wave form for instrument BRIT  (F5)
      	P9 = wave form for instrument BUZZ  (F6)

      The names of the functions present are F1, F2, F3, F4, F5 and  F6.
      F2 is a mezzo-legato envelope; F3 is a semi-staccato envelope;  F1
      is a simple sine wave; F4 is  a wave using only the 1st, 3rd,  5th
      and 7th harmonics;  F5 has an  assortment of harmonics  up to  the
      11th and F6 is a triangular pulse.  The details of these waves may
      be seen in the file INIT.MUS.

      There are  many  more unit  generators  available than  have  been
      discussed in this document.  See MUS10.LCS[UP,DOC]  for a detailed
      description of the MUS10 program.

      All the  unit generators  discussed have  been  non-interpolating.
      Interpolating forms  of  most  unit generators  are  available  by
      adding a  first letter  'Z'.  (ZOSCIL,  ZCOSCIL, ZNOSCIL,  ZINTRP)
      These unit generators  give smoother sound  (especially for  long,
      slow glissandos)  but  they are  a  luxury in  that  they  involve
      considerably more computation time.
        
        
      'MUS10'  computes  sound  in  12-bit samples, at 12800 samples per 
      second, unless told  otherwise.   The other sample size  available 
      is 18.   (Really 16.)  
      To change from the default size, type:  BITS←18;
        
      The 'MUS10' program always writes a record of information (HEADER)
      at the  beginning  of  each  sound  file.   This  record  contains
      information about the sampling rate, number of channels, bits  per
      sample, amplitude, etc.   Thus  the playback  programs may  adjust
      automatically to each set of conditions.
        
      The default name for sound files  is 'TEST.SND'.  The name may  be
      changed in the following manner.
        
      	OUTFILE←"NAME.SND"; <NAME may be any desired name.
        
      However when it comes time to play the sound this new NAME must be
      typed.  If the extension '.SND' has been used it need not be typed
      for playing.
 
 
      ***** PUTTING SOUND ON A UDP *****
 
      When using a UDP (User Disk Pack) several steps must be followed.

      1. Be sure the proper disk pack is mounted.  For instructions on
         this ask someone who is already familiar with the process.
         DON'T TRY TO DO THIS WITHOUT INSTRUCTION!
 
      2. Assign the UDP to be used.  Create a directory area.
         Again, ask someone who knows how this is done.
 
      3. Now the device name must appear in your OUTFILE specification.
          Example:  OUTFILE←"UDP2:NAME.SND";
 
      From this point on all should proceed in a normal fashion.
 
 
      ***** PUTTING SOUND ON MAGTAPE ***(NOT GENERALLY USEFUL)****
 
      1. Assign the tape drive. (Only MTA0 or MTA1 are available.)
      2. Mount the tape and be sure it is at the "load point".

      3. The device name must appear in your OUTFILE specification.
          Example:  OUTFILE←"MTA0:X.X";
         In this case the file name, X.X, is a dummy.
         When using tape, this program does not rewrite the header
         when the computation is done.  Hence things like the maximum
         amplitude and the total duration will not be found in the
         header.  To cause the duration to appear in the header the
         variable MTADUR may be used.  Example: MTADUR←54.03; will
         put that duration into the header on a tape.
 
      4. To play the sound which has been computed onto tape, the tape
         must be rewound and then copied to the DSK after which it can
         be heard by using the PLAY program.


      ***** SAVE FEATURE ***( SAVCNT )*****
 
      When  doing  long  computations (more than c.30" of sound) it is 
      generally  advisable  to  use the SAVE feature.  This feature is 
      activated through the variable SAVCNT.  A number put into SAVCNT
      tells how many "records" are to be written between each SAVE of
      the program.  Normally 100 will be a good number.  (SAVCNT←100;)
      With this feature the program may be stopped and then restarted 
      at a later time.  Each time the program is saved a file called
      NAME.SAV is written, where NAME is the name of the input notelist
      being used.  In this case the program may be restarted by typing
      RUN NAME.SAV.  When the computation is finished  the  .SAV file
      should be deleted.
      ****** Information re. FUNC.  To run type R FUNC ********************
        
      This program is largely self-instructional.   Practice a bit with  it
      before attempting to do serious work.  The output of the FUNC program
      will always be a file with the extension '.FUN'.  File names can have
      no more than 5  letters and function  names can have  no more than  3
      letters.  Up to 10 functions may be stored in each .FUN file.  (These
      files are designed to be edited  only!!! by the FUNC program  itself.
      Use of  the  'ET'  editor  with .FUN  files  usually  destroys  their
      format.)

      CRUNCH:  Any two functions already in  a  single  .FUN  file  may  be
      "crunched" together.  Also, a function may be created by  either  the
      SEG  or  SYNTH  routines and then if instead of typing "F" for FINISH
      the letter "C" is typed the program will jump immediately to "crunch"
      mode.   At  this  point  the  new  function  may be combined with any
      function found in the file presently in core.  Note however that once
      this new function  is  processed  by  any  of  "crunch"  options  its
      original  form  cannot be regained without going back to ordinary SEG
      or SYNTH mode.
        
      PLOTTING:  If "SP" (=see on the plotter) is  typed  single  functions
      can  be  drawn  on  the  Calcomp  plotter.   The size asked for is in
      inches. "SA" (=see all on plotter) will plot all the functions  found
      in  a single file.
      "SX"  (=see all on the XGP)  will draw all functions  from  a  single
      file  in  the  proper  size for printing by the XGP.  In order to use
      "SX" you must!!! follow the next steps exactly!!!
        
      	Before running FUNC type: A DSK PLT <CR>. This will cause the
      	instructions FUNC sends to the plotter to  be  written  in  a
      	file on the disk.
        
      	When  the  FUNC  program  finishes  then  type  R X <CR>.
      	This runs a  program  called  X  which  converts  plotter
      	information to XGP commands.
        
      	X will ask you 5 questions.  You should answer as follows:
        
      		PLOT.BIN <CR>		(the file name)
      		<CR>			(plot slice?)
      		5  <CR>			(shift 5 inches)
      		<CR>			(use default value of 11".)
      		1  <CR>			(1 inch from the left)
      		Y			(yes, delete the plot file)
        
        

      ********* Information re. WAVES.   To run it type R WAVES  **********
        
      This  will  allow  you  to  display  the  actual wave shapes of sound
      computed by MUS10.  The TEST.SND file thus produced is read by WAVES.
        
      (When  WAVES  asks  "TYPE  FILE  NAME",  a  simple  <CR>  will be the
      equivalent of typing TEST.SND <CR> .)
        

      ********* Information re. MIXER.   To run type R MIXER  *************

      This program allows  you to  mix or  splice 2  sound files  together.
      There are a few restrictions in the use of this program.  Both  files
      must use the same sampling rate, the same number of channels and  the
      the same bit size.  The amplitudes of each file may be scaled as  you
      wish.  After mixing 2 files, the result  may be in turn mixed with  a
      third file, etc.